#!/usr/bin/evn python
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   文件名称 :     auto_slots_meta
   文件功能描述 :   功能描述
   创建人 :       小钟同学
   创建时间 :          2021/12/29
-------------------------------------------------
   修改描述-2021/12/29:         
-------------------------------------------------
"""


class AutoSlotsMeta(type):
    '''
    自动添加slots的元类
    class AutoSlotsMeta(type):
    def __new__(mcs, *args, **kwargs):
        if args[0] != "AutoSlots":
            args[2]["__slots__"] = tuple([k for k in args[2].get("__annotations__").keys()])
        return super().__new__(mcs, *args, **kwargs)
    class AutoSlots(metaclass=AutoSlotsMeta):
        pass
    '''

    def __new__(mcs, *args, **kwargs):
        if args[0] != "AutoSlots":
            args[2]["__slots__"] = tuple([k for k in args[2].get("__annotations__").keys()])
        return super().__new__(mcs, *args, **kwargs)


class AutoSlots(metaclass=AutoSlotsMeta):
    pass
